package encrypt

import (
	"crypto/sha256"
	"crypto/hmac"
	"encoding/hex"
)

func Sha256Hex(data []byte) string {
	return hex.EncodeToString(Sha256(data))
}

func Sha256(data []byte) []byte {
	digest := sha256.New()
	digest.Write(data)
	return digest.Sum(nil)
}

func HmacSha256(str, secret string) string {
	key := []byte(secret)
	h := hmac.New(sha256.New, key)
	h.Write([]byte(str))

	return hex.EncodeToString(h.Sum(nil))
}
